var basefun = (function () {
  var screenHeight;
  if (window.innerHeight) {
    screenHeight = window.innerHeight;
  } else if ((document.body) && (document.body.clientHeight)) {
    screenHeight = document.body.clientHeight;
  }
  document.getElementsByTagName('html')[0].height = screenHeight;
  document.getElementsByTagName('body')[0].height = screenHeight;
})();

function getUrlParam(key) {
  // 获取参数
  var url = window.location.search;
  // 正则筛选地址栏
  var reg = new RegExp("(^|&)" + key + "=([^&]*)(&|$)");
  // 匹配目标参数
  var result = url.substr(1).match(reg);
  //返回参数值
  return result ? decodeURIComponent(result[2]) : null;
}

function getParams(key) {
  var url = window.location.pathname;
  var arr = url.split('/');
  var index = arr.indexOf(key);
  return arr[index + 1];
}

function getParam(key) {
  return getUrlParam(key) ? getUrlParam(key) : getParams(key) ? getParams(key) : null;
}


export default {
  getParam,
  basefun
}
